package com.icoolkj.learn.juc.base;

/**
 * @author icoolkj
 * @version 1.0
 * @description 线程优先级，调度器优先调度该线程，但仅仅是一个提示，调度器可以忽略它
 * @createDate 2025/03/04 12:35
 */
public class ThreadPriorityDemo {
    public static void main(String[] args) {
        Runnable runnable1 = () -> {
            int count = 0;
            for (; ;) {
                System.out.println(Thread.currentThread().getName() + ": " + count++);
            }
        };
        Runnable runnable2 = () -> {
            int count = 0;
            for (; ;) {
                System.out.println(Thread.currentThread().getName() + ": " + count++);
            }
        };
        Thread thread1 = new Thread(runnable1, "t1");
        Thread thread2 = new Thread(runnable2, "t2");

        thread1.setPriority(Thread.MIN_PRIORITY);
        thread2.setPriority(Thread.MAX_PRIORITY);

        thread1.start();
        thread2.start();
    }
}
